package cn.hwadee.muying.enums;

import com.baomidou.mybatisplus.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;

import java.io.Serializable;

/**
 * @Auther: asus01
 * @Date: 2018/8/14 16:33
 * @Description:
 */
public enum Status implements IEnum {
    FIRST_FOLLOW(1,"初次跟进"),
    FINISH_REGISTER(2,"注册成功"),
    RECEIVE_SERVICE(3,"接受服务"),
    FINISH_ORDER(4,"完成订单");

    private int value;
    private String desc;
    Status(final int value, final String desc){
        this.value=value;
        this.desc=desc;
    }

    @Override
    public Serializable getValue() {
        return this.value;
    }

    @JsonValue
    public String getDesc(){
        return this.desc;
    }

    public static Status getById(int id) {
        Status[] statuses = Status.values();
        for(Status status : statuses){
            if(status.value == id){
                return status;
            }
        }
        return null;
    }

    public static Status getByDesc(String desc) {
        Status[] statuses = Status.values();
        for(Status Status : statuses){
            if(Status.desc.equals(desc)){
                return Status;
            }
        }
        return null;
    }

}
